package com.oneandseven.dajia.openai;

import java.util.List;

public class ChatCompletionsRequest {

    private String model;
    private final List<ChatRequestMessage> messages;
    private Double temperature;
    private Integer max_tokens;
    private ResponseFormat response_format;

    public ChatCompletionsRequest(List<ChatRequestMessage> messages) {
        this.messages = messages;
        this.temperature = 1D;
        this.max_tokens = 1024;
        this.response_format = new ResponseFormat("text");
    }

    public ChatCompletionsRequest setModel(String model) {
        this.model = model;
        return this;
    }

    public ChatCompletionsRequest setTemperature(double temperature) {
        this.temperature = temperature;
        return this;
    }

    public ChatCompletionsRequest setMax_tokens(int max_tokens) {
        this.max_tokens = max_tokens;
        return this;
    }

    public ChatCompletionsRequest setResponse_format(ResponseFormat response_format) {
        this.response_format = response_format;
        return this;
    }

    public static class ResponseFormat{
        private String type;

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public ResponseFormat (String type) {
            this.type = type;
        }
    }

    public double getTemperature() {
        return temperature;
    }

    public int getMax_tokens() {
        return max_tokens;
    }

    public ResponseFormat getResponse_format() {
        return response_format;
    }

    public List<ChatRequestMessage> getMessages() {
        return messages;
    }

    public String getModel() {
        return model;
    }

    public static class ChatRequestMessage {
        private String role;

        private String content;

        public ChatRequestMessage(String role, String content) {
            this.role = role;
            this.content = content;
        }

        public String getRole() {
            return role;
        }

        public void setRole(String role) {
            this.role = role;
        }

        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }
    }
}